package com.shop.shop.util;

import com.shop.shop.model.Chart;
import com.shop.shop.model.ChartMysql;
import com.shop.shop.model.Order;
import com.shop.shop.model.OrderMysql;
import com.sun.org.apache.xpath.internal.operations.Or;

import java.util.ArrayList;
import java.util.List;

public class MysqlTransferUtils {
    public static Chart transfer(ChartMysql chartMysql){
        return new Chart(chartMysql);
    }
    public static ChartMysql transfer(Chart chart){
        return new ChartMysql(chart);
    }
    public static Order transfer(OrderMysql orderMysql){
        return new Order(orderMysql);
    }
    public static OrderMysql transfer(Order order){
        return new OrderMysql(order);
    }
    //java伪泛型，泛型只存在编译之前，编译时，擦除泛型信息，java编译器在编译前检查泛型是否出错，无措允许编译，否则不允许编译
    public static List<Chart> transferToChartList(List<ChartMysql> chartMysqlList){
        List<Chart> list1=new ArrayList<>();
        for (ChartMysql chartMysql:chartMysqlList){
            list1.add(new Chart(chartMysql));
        }
        return list1;
    }
    public static List<ChartMysql> transferToChartMysqlList(List<Chart> chartList){
        List<ChartMysql> list=new ArrayList<>();
        for (Chart chart:chartList){
            list.add(new ChartMysql(chart));
        }
        return list;
    }
    public static List<Order> transferToOrderList(List<OrderMysql> orderMysqlList){
        List<Order> list=new ArrayList<>();
        for (OrderMysql orderMysql:orderMysqlList){
            list.add(new Order(orderMysql));
        }
        return list;
    }
    public static List<OrderMysql> transferToOrderMysqlList(List<Order> orderList){
        List<OrderMysql> list=new ArrayList<>();
        for (Order order:orderList){
            list.add(new OrderMysql(order));
        }
        return list;
    }
}
